#ifndef MESSAGE_INPUT_H_INCLUDED
#define MESSAGE_INPUT_H_INCLUDED

/*
* Copyright (c) 2010 Michael Collins
*
* This file is part of TerraFirma.
*
* TerraFirma is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TerraFirma is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TerraFirma.  If not, see <http://www.gnu.org/licenses/>.
*/
#include <message_header.h>

namespace engine {
    /** The task id code of the logic thread
    */
    static const task_id input_thread_tid = get_task_id_by_name("input_thread");

    enum { ENABLE,
           LOAD_CONF,
           SAVE_CONF,
           QUIT,
           TEXT_MODE,
           CONTROL_MODE,
           BIND, UNBIND,
           ADD_CONTROL,
           REMOVE_CONTROL};

    //With this message passed, we can turn on, or silence outgoing messages
    //Mostly so we don't have to deal with unnecessary network traffic and processing
    struct Enable_Input_Events_Message
    {
        Enable_Input_Events_Message(bool on = true) :
            header(input_thread_tid, CONTROL_MSG, ENABLE, sizeof(Enable_Input_Events_Message)),
            enabled(on) {}

        message_header header;
        bool enabled;
    };

    struct Load_Input_Config_Message
    {
        Load_Input_Config_Message() :
            header(input_thread_tid, CONTROL_MSG, LOAD_CONF, sizeof(Load_Input_Config_Message)) {}

        message_header header;
        char filename [64];
    };

    struct Save_Input_Config_Message
    {
        Save_Input_Config_Message() :
            header(input_thread_tid, CONTROL_MSG, SAVE_CONF, sizeof(Save_Input_Config_Message)) {}

        message_header header;
        char filename [64];
    };

    typedef message<sizeof(Load_Input_Config_Message)> control_msg;



//    struct control_msg
//    {
//    public:
//        control_msg() : m.header(input_thread_tid, CONTROL_MSG, 0xf, sizeof(message_header)) {}
//        //Copy constructor only copies as much as is necessary
//        control_msg(const control_msg& n)
//            {memcpy(this, &n, n.m.header.get_size());}
//        control_msg& operator= (const control_msg& n) {memcpy(this, &n, n.m.header.get_size()); return *this;}
//
//        uint8_t type() {return (m.header.type & 0xf);}
//
//        //This is mostly just to make sure that we have enough room for the largest type of actual message
//        union
//        {
//            message_header header;
//
//        } m;
//    };

}


#endif // MESSAGE_INPUT_H_INCLUDED
